package com.xll.service.impl;

import com.xll.entity.Remark;
import com.xll.mapper.RemarkMapper;
import com.xll.service.RemarkService;
import com.xll.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class RemarkServiceImpl implements RemarkService {

    @Autowired
    private RemarkMapper remarkMapper;
    @Override
    public Result delete(Long id) {
        remarkMapper.delete(id);
        return Result.success("评价记录删除成功");
    }

    @Override
    public Result update(Remark remark) {
        remarkMapper.update(remark);
        return Result.success("评价记录成功");
    }

    @Override
    public Result findByScenicId(Long scenicId) {
        if(scenicId==null){
            return  Result.fail("请传递景区id");
        }
        List<Remark> remarkList = remarkMapper.findByScenicId(scenicId);
        return Result.success("该景区评价获取成功",remarkList);
    }

    @Override
    public Result insert(Remark remark) {
        remarkMapper.insert(remark);
        return Result.success("评价记录添加成功");
    }

    @Override
    public Result findByCreateUser(String createUser) {
        List<Remark> remarkList = remarkMapper.findByUserName(createUser);
        return Result.success("该景区评价获取成功",remarkList);
    }
}
